<script>
	import HzSafeArea from "@/components/layout/hz/hz-safe-area.vue";
	import SelectUser from "@/components/selectUser/index.vue";
	import SelectAddress from "@/components/selectAddress/index.vue";
	import Calendar from "@/mall_subpages/components/calendar/components/wu-calendar/wu-calendar.vue";

	import {
		getGoodsDetail,
		addEleCouponOrders,
		addPackProductOrders,
		addProductOrders,
		getPointsExchangeRatio,
		getAcceptAddressList,
	} from "@/api/mall";
	import {
		GetUserCoupons,
		getUserIntegral
	} from "@/api/homePage.js";

	export default {
		name: "predetermined",
		components: {
			HzSafeArea,
			SelectUser,
			SelectAddress,
			Calendar,
		},
		data() {
			const today = this.getFormattedDate(new Date());
			const tomorrow = this.getFormattedDate(this.getTomorrowDate());
			const endLimit = this.getFormattedDate(this.getDateAfterDays(15));

			return {
				checked: false,
				id: "",
				type: "",
				hotelInfo: {
					name: "",
					roomType: "房间类型",
					price: 0,
					image: "",
					businessId: "",
					productId: "",
					productSpecId: "",
					ProductSpecList: [],
					ProductAttributes: [],
				},
				dateRange: [today, tomorrow],
				datePickerStart: today, // 日期选择器的开始日期(今天)
				datePickerEnd: endLimit,
				// 门票相关
				ticketDate: today,
				timeSlots: [],
				selectedTimeSlot: 0,
				// 通用
				roomNum: 1,
				remark: "",
				guests: [],
				currentSelectedGuests: [],
				showUserSelector: false,
				// 其他服务相关
				selectedService: "",
				// 优惠券相关数据
				hasCoupons: false,
				useCoupons: [],
				couponTotalDiscount: 0,
				// 价格动画
				lastTotalPrice: 0,
				// 积分相关
				pointsRatio: 1, // 积分兑换比例
				isPointsPayment: false, // 是否使用积分支付
				// 收货地址相关
				selectedAddress: null, // 选中的收货地址
				showAddressSelector: false, // 是否显示地址选择器
				// 提交订单防重复点击
				isSubmitting: false, // 是否正在提交订单
				userPoints: 0, // 用户当前积分
				priceList: [], // 价格列表
				selectDate: [], // 选择时间
			};
		},
		computed: {
			isReservation() {
				return (
					this.selectedSpecName &&
					this.selectedSpecName.includes("预约套餐") &&
					this.type === 13
				);
			},
			roomList() {
				if (
					this.type == 13 &&
					this.selectedSpecName &&
					!this.selectedSpecName.includes("预约套餐")
				) {
					if (this.selectDate && this.selectDate.length > 0 && this.priceList.length > 0) {
						return this.selectDate.map(dateStr => {
							const priceObj = this.priceList.find(p => p.date === dateStr);
							const price = priceObj?.price ?? this.hotelInfo.price;
							const dateObj = this.formatDateObject(dateStr);
							return {
								date: `${dateObj.month}月${dateObj.day}日`,
								price: price,
								room: this.roomNum,
								totalPrice: price * this.roomNum
							};
						});
					}
					return [];
				}
				return [];
			},
			// 计算住宿天数
			nightsCount() {
				// 预约套餐按1晚计，不依赖selectDate
				return this.isReservation ? 1 : this.selectDate.length;
			},

			// 格式化入住日期
			checkInDate() {
				return this.formatDateObject(this.dateRange[0]);
			},

			// 格式化离店日期
			checkOutDate() {
				return this.formatDateObject(this.dateRange[1]);
			},

			// 格式化门票日期
			formatTicketDate() {
				if (!this.ticketDate) return "";
				const {
					month,
					day,
					weekDay
				} = this.formatDateObject(this.ticketDate);
				return `${month}月${day}日 ${weekDay}`;
			},

			// 计算总价
			totalPrice() {
				let basePrice = this.hotelInfo.price;

				// 如果选择了特定服务，使用该服务的价格
				if (this.type !== 11 && this.selectedService) {
					const selectedServiceObj = this.hotelInfo.ProductSpecList?.find(
						(service) => service.Id === this.selectedService
					);

					if (selectedServiceObj && selectedServiceObj.Price !== null) {
						basePrice = selectedServiceObj.Price;
					}
				}
				// 计算基本总价
				let totalPrice = basePrice * this.roomNum;

				// 如果是酒店类型，需要根据所选日期区间和价格日历累加总价
				if (this.type === 13) {
					// 预约套餐：总价 = 规格价 × 数量
					if (this.isReservation) {
						totalPrice = basePrice * this.roomNum;
					} else {
					let total = 0;
					if (
						this.selectDate &&
						this.selectDate.length > 0 &&
						this.priceList &&
						this.priceList.length > 0
					) {
						this.selectDate.forEach(dateStr => {
							const priceObj = this.priceList.find(p => p.date === dateStr);
							const dayPrice = priceObj?.price ?? this.hotelInfo.price;
							total += dayPrice;
						});
						totalPrice = total * this.roomNum;
					} else {
						totalPrice = basePrice * this.roomNum * this.nightsCount;
					}
					}
				}

				// 减去优惠券折扣 - 只在非积分模式下计算优惠券
				if (!this.shouldUsePoints && this.couponTotalDiscount > 0) {
					totalPrice -= this.couponTotalDiscount;
					// 确保价格不低于0
					totalPrice = Math.max(0, totalPrice);
				}

				// 四舍五入保留两位小数
				totalPrice = Math.round(totalPrice * 100) / 100;

				return totalPrice;
			},

			// 计算积分总额
			totalPoints() {
				if (!this.isPointsPayment) return 0;
				const basePrice = this.hotelInfo.price;
				const basePoint = Math.ceil(basePrice * this.pointsRatio);
				return basePoint * this.roomNum;
			},

			// 判断是否为积分支付
			shouldUsePoints() {
				return this.isPointsPayment;
			},

			selectedSpecName() {
				// 获取当前选择房间的 SpecName
				let spec = null;
				if (this.type === 11 || this.type === 18) {
					// 门票/活动类型，取 timeSlots 当前选中项
					if (
						this.timeSlots &&
						this.timeSlots.length > 0 &&
						this.timeSlots[this.selectedTimeSlot]
					) {
						const slot = this.timeSlots[this.selectedTimeSlot];
						// 通过 productSpecId 找到 ProductSpecList 对应项
						spec = this.hotelInfo.ProductSpecList.find(
							(s) => s.Id === slot.productSpecId
						);
					}
				} else {
					// 其他类型，取 selectedService
					spec = this.hotelInfo.ProductSpecList.find(
						(s) => s.Id === this.selectedService
					);
				}
				return spec && spec.SpecName ? spec.SpecName : "";
			},
		},
		onLoad(options) {
			if (options) {
				this.id = options.id || "";
				this.type = parseInt(options.type) || "";
				// 判断是否使用积分支付 - 根据integral参数
				this.isPointsPayment =
					options.integral === "true" || options.integral === true;
			}
			// 设置导航栏标题
			uni.setNavigationBarTitle({
				title: this.$t("order.createOrder"),
			});

			console.log(
				"初始化页面，商品ID:",
				this.id,
				"类型:",
				this.type,
				"是否积分支付:",
				this.isPointsPayment
			);

			// 如果是积分支付类型，获取积分比例 获取用户积分
			if (this.isPointsPayment) {
				this.getPointsRatio();
				this.getUserPoints();
			}

			// 先初始化产品基础信息
			this.init();

			// 获取优惠券信息 - 只在非积分模式下获取
			if (!this.isPointsPayment) {
				this.getCoupon();
			}

			// 如果是实物商品，获取默认收货地址
			if (this.type === 2) {
				this.getDefaultAddress();
			}

			// 如果是门票类型或活动类型，延迟生成场次数据，确保产品信息已加载
			if (this.type === 11 || this.type === 18) {
				console.log("门票/活动类型，准备加载场次信息");
				// 延迟执行，确保init方法完成
				setTimeout(() => {
					console.log("延迟执行generateTimeSlots，商品数据:", this.hotelInfo);
					this.generateTimeSlots();
				}, 500);
			}

			// 添加页面显示监听器，用于页面返回时刷新数据
			uni.$on("updateUserList", this.refreshUserSelector);
		},
		watch: {
			// 监听总价变化
			totalPrice(newVal, oldVal) {
				if (oldVal && newVal !== oldVal) {
					this.lastTotalPrice = parseFloat(oldVal);
				}
			},
			selectedSpecName(newVal) {
				if (newVal && newVal.includes("预约套餐")) {
					// 设置为本年12月30日至12月31日
					const year = new Date().getFullYear();
					const start = `${year}-12-30`;
					const end = `${year}-12-31`;
					this.dateRange = [start, end];
					this.datePickerStart = start;
					this.datePickerEnd = end;
				}
			},
		},
		methods: {
			changeCheked() {
				this.checked = !this.checked;
			},
			goToTermsDetail(id) {
				uni.navigateTo({
					url: `/ticket_subpages/index/article?id=${id}`
				});
			},
			openCalendar() {
				this.$refs.calendar.open();
			},
			calendarConfirm(e) {
				console.log(e);
			},
			dateRangeFlag(range, dateRange) {
				// 无效输入处理
				if (typeof range !== "string" || range.trim() === "") {
					return true;
				}

				const trimmedRange = range.trim();

				// 处理新的SpecName格式：'2025/07/01-2025/08-01&周五-周六'
				if (trimmedRange.includes('&')) {
					const [dateRangeStr, weekRange] = trimmedRange.split('&');

					// 解析日期范围
					const [startDateStr, endDateStr] = dateRangeStr.split('-');
					const startDate = new Date(startDateStr);
					const endDate = new Date(endDateStr);

					const checkIn = new Date(dateRange[0]);
					const checkOut = new Date(dateRange[1]);

					// 检查选择的日期范围是否在规格的日期范围内
					if (checkIn < startDate || checkOut > endDate) {
						return false;
					}

					// 星期映射表
					const weekMap = {
						周日: 0,
						周一: 1,
						周二: 2,
						周三: 3,
						周四: 4,
						周五: 5,
						周六: 6,
					};

					// 解析星期范围
					if (weekRange.includes('-')) {
						// 星期区间，如：周五-周六
						const [startWeek, endWeek] = weekRange.split('-').map(s => s.trim());
						const startNum = weekMap[startWeek];
						const endNum = weekMap[endWeek];

						const checkInDay = checkIn.getDay();
						const checkOutDay = checkOut.getDay();

						// 检查入住日是否在指定范围内
						let isCheckInValid;
						if (startNum <= endNum) {
							isCheckInValid = checkInDay >= startNum && checkInDay <= endNum;
						} else {
							isCheckInValid = checkInDay >= startNum || checkInDay <= endNum;
						}

						// 检查离店日是否在指定范围内或结束日的下一天
						let isCheckOutValid;
						const nextDayOfEnd = (endNum + 1) % 7;

						if (startNum <= endNum) {
							// 不跨周的情况
							isCheckOutValid =
								(checkOutDay >= startNum && checkOutDay <= endNum) ||
								checkOutDay === nextDayOfEnd;
						} else {
							// 跨周的情况
							isCheckOutValid =
								checkOutDay >= startNum ||
								checkOutDay <= endNum ||
								checkOutDay === nextDayOfEnd;
						}

						return isCheckInValid && isCheckOutValid;
					} else {
						// 单一星期，如：周五
						const weekName = weekRange.trim();
						const weekNum = weekMap[weekName];
						const checkInDay = checkIn.getDay();
						const checkOutDay = checkOut.getDay();

						// 必须满足：入住日为指定星期，且只住1晚
						return (
							(checkOut - checkIn) / (1000 * 3600 * 24) === 1 &&
							checkInDay === weekNum
						);
					}
				}

				// 兼容旧的格式：'周日' 或 '周日-周六'
				if (
					!/^(周日|周一|周二|周三|周四|周五|周六)(\s*-\s*(周日|周一|周二|周三|周四|周五|周六))?$/.test(
						trimmedRange
					)
				) {
					return true;
				}

				const checkIn = new Date(dateRange[0]);
				const checkOut = new Date(dateRange[1]);
				if (checkOut <= checkIn) {
					return false;
				}

				// 星期映射表
				const weekMap = {
					周日: 0,
					周一: 1,
					周二: 2,
					周三: 3,
					周四: 4,
					周五: 5,
					周六: 6,
				};

				// 处理单个星期
				if (!trimmedRange.includes("-")) {
					const weekNum = weekMap[trimmedRange];
					const checkInDay = checkIn.getDay();
					const checkOutDay = checkOut.getDay();
					// 必须满足：入住日为指定星期，且只住1晚
					return (
						(checkOut - checkIn) / (1000 * 3600 * 24) === 1 &&
						checkInDay === weekNum
					);
				}

				// 处理星期范围
				const [startWeek, endWeek] = trimmedRange.split("-").map((s) => s.trim());
				const startNum = weekMap[startWeek];
				const endNum = weekMap[endWeek];

				// 计算住宿天数
				const nightsCount = Math.ceil((checkOut - checkIn) / (1000 * 3600 * 24));

				// 如果是跨7天的情况，只有周日-周六才允许
				if (nightsCount >= 7) {
					return startNum === 0 && endNum === 6; // 只有周日-周六才允许跨7天
				}

				const checkInDay = checkIn.getDay();
				const checkOutDay = checkOut.getDay();

				// 检查入住日是否在指定范围内
				let isCheckInValid;
				if (startNum <= endNum) {
					isCheckInValid = checkInDay >= startNum && checkInDay <= endNum;
				} else {
					isCheckInValid = checkInDay >= startNum || checkInDay <= endNum;
				}

				// 检查离店日是否在指定范围内或结束日的下一天
				let isCheckOutValid;
				const nextDayOfEnd = (endNum + 1) % 7;

				if (startNum <= endNum) {
					// 不跨周的情况
					isCheckOutValid =
						(checkOutDay >= startNum && checkOutDay <= endNum) ||
						checkOutDay === nextDayOfEnd;
				} else {
					// 跨周的情况
					isCheckOutValid =
						checkOutDay >= startNum ||
						checkOutDay <= endNum ||
						checkOutDay === nextDayOfEnd;
				}

				return isCheckInValid && isCheckOutValid;
			},
			// 根据规格值查找对应的规格属性名
			findAttributeName(specValue) {
				if (
					!this.hotelInfo.ProductAttributes ||
					!Array.isArray(this.hotelInfo.ProductAttributes) ||
					!specValue
				) {
					return "";
				}

				// 将规格值按空格分割
				const specValueItems = specValue.split(" ");

				// 遍历ProductAttributes查找匹配的规格
				for (const attribute of this.hotelInfo.ProductAttributes) {
					// 检查ItemName是否为数组
					if (attribute.ItemName && Array.isArray(attribute.ItemName)) {
						// 检查specValueItems中的每个值是否在ItemName数组中
						for (const item of specValueItems) {
							if (item && attribute.ItemName.includes(item)) {
								return attribute.Name;
							}
						}
					}
				}

				return "";
			},

			// 格式化日期对象
			formatDateObject(dateStr) {
				if (!dateStr) return "";
				const date = new Date(dateStr);
				const month = date.getMonth() + 1;
				const day = date.getDate();
				const weekDay = ["周日", "周一", "周二", "周三", "周四", "周五", "周六"][
					date.getDay()
				];
				return {
					month,
					day,
					weekDay,
				};
			},

			// 应用优惠券折扣
			applyDiscount(price, coupon) {
				if (!coupon || Object.keys(coupon).length === 0) return price;

				const fullReduceAmount = coupon?.CouponTemple?.FullReduceAmount;
				const minimumConsumption = coupon?.CouponTemple?.MinimumConsumption;

				if (price >= minimumConsumption) {
					if (price >= fullReduceAmount) {
						return price - fullReduceAmount;
					} else {
						return 0.0;
					}
				}

				return price;
			},
			//获取日历价格
			getCalendarPrices(specList) {
				// 获取当前日期
				const today = new Date();
				const year = today.getFullYear();
				const month = today.getMonth(); // 0-11

				// 生成三个月的所有日期
				const allDates = [];
				for (let m = 0; m < 3; m++) {
					// 修复月份计算逻辑，确保正确处理月份边界
					const targetYear = year + Math.floor((month + m) / 12);
					const targetMonth = (month + m) % 12;
					
					const date = new Date(targetYear, targetMonth, 1);
					const y = date.getFullYear();
					const mo = date.getMonth();
					const daysInMonth = new Date(y, mo + 1, 0).getDate();
					
					console.log(`生成月份: ${y}年${mo + 1}月，共${daysInMonth}天`);
					
					for (let d = 1; d <= daysInMonth; d++) {
						const dayDate = new Date(y, mo, d);
						const dateStr = this.getFormattedDate(dayDate);
						allDates.push({
							date: dateStr,
							day: dayDate.getDay(),
						}); // day: 0-6, 0为周日
					}
				}

				console.log(`总共生成${allDates.length}个日期，日期范围: ${allDates[0]?.date} 到 ${allDates[allDates.length - 1]?.date}`);

				// 规格名到星期数字的映射
				const weekMap = {
					周日: 0,
					周一: 1,
					周二: 2,
					周三: 3,
					周四: 4,
					周五: 5,
					周六: 6,
				};

				// 收集所有排除日期（EX=规则）
				const excludeDates = new Set();
				for (const spec of specList) {
					if (!spec.SpecName) continue;
					const specName = spec.SpecName.trim();

					// 解析排除日期规则（EX=07/28&08/02&08/05）
					if (specName.includes('EX=')) {
						const exPart = specName.split('EX=')[1];
						if (!exPart) continue;

						// 提取排除日期列表（格式为 MM/DD）
						const dateStrs = exPart.split('&');
						for (const dateStr of dateStrs) {
							if (/^\d{2}\/\d{2}$/.test(dateStr)) {
								// 解析月份和日期
								const [monthStr, dayStr] = dateStr.split('/');
								const excludeMonth = parseInt(monthStr) - 1; // 月份转为0-11，使用不同变量名避免冲突
								const day = parseInt(dayStr);

								// 在日历数据中查找匹配日期
								for (const d of allDates) {
									const dDate = new Date(d.date);
									if (dDate.getMonth() === excludeMonth && dDate.getDate() === day) {
										excludeDates.add(d.date); // 添加到排除集合
									}
								}
							}
						}
					}
				}

				let priceList = [];
				// 酒店类型且包含"预约套餐"的特殊处理
				if (
					this.type === 13 &&
					this.selectedSpecName &&
					this.selectedSpecName.includes("预约套餐")
				) {
					const selectedSpec = this.hotelInfo.ProductSpecList.find(
						s => s.Id === this.selectedService
					);
					const price =
						selectedSpec && selectedSpec.Price != null ?
						selectedSpec.Price :
						this.hotelInfo.price;
					priceList = allDates.map(({
						date
					}) => ({
						date,
						price: price,
						info: "￥" + price,
						disable: !price, // 当price有值时，disable为false，否则为true
						infoColor: "#6ac695",
					}));
				} else {
					// 生成价格日历
					priceList = allDates.map(({
						date,
						day
					}) => {
						let matchedPrice = null;
						let matchedSpec = null;
						
						// 调试特定日期
						const isDebugDate = date === '2025-08-31';
						if (isDebugDate) {
							console.log(`=== 调试日期: ${date} (星期${day}) ===`);
							console.log('当前specList:', specList);
						}
						
						for (const spec of specList) {
							if (!spec.SpecName) continue;
							const specName = spec.SpecName.trim();

							// 解析新的SpecName格式：'2025/07/01-2025/08-01&周五-周六'
							if (specName.includes('&') && !specName.includes('EX=')) {
								const [dateRange, weekRange] = specName.split('&');

																// 解析日期范围
								const [startDateStr, endDateStr] = dateRange.split('-');
								
								// 修复日期解析：将 YYYY/MM/DD 格式转换为 YYYY-MM-DD 格式
								const startDate = new Date(startDateStr.replace(/\//g, '-'));
								const endDate = new Date(endDateStr.replace(/\//g, '-'));
								const currentDate = new Date(date);
								
								// 转换为标准格式用于字符串比较
								const startDateFormatted = startDateStr.replace(/\//g, '-');
								const endDateFormatted = endDateStr.replace(/\//g, '-');
								
								// if (isDebugDate) {
								// 	console.log(`  原始日期字符串: ${startDateStr} 到 ${endDateStr}`);
								// 	console.log(`  转换后日期: ${startDate.toISOString()} 到 ${endDate.toISOString()}`);
								// 	console.log(`  当前日期: ${currentDate.toISOString()}`);
								// 	console.log(`  格式化后字符串: ${startDateFormatted} 到 ${endDateFormatted}`);
								// }
								
								// 检查当前日期是否在日期范围内
								// 使用日期字符串比较避免时区问题
								const currentDateStr = date; // 格式: YYYY-MM-DD
								
								if (currentDateStr >= startDateFormatted && currentDateStr <= endDateFormatted) {
									if (isDebugDate) {
										console.log(`检查spec: ${specName}`);
										console.log(`  日期范围: ${startDateStr} 到 ${endDateStr}`);
										console.log(`  当前日期: ${date}`);
										console.log(`  星期范围: ${weekRange}`);
										console.log(`  当前星期: ${day}`);
										console.log(`  ✓ 日期在范围内`);
									}
									
									// 解析星期范围
									if (weekRange.includes('-')) {
										// 星期区间，如：周五-周六
										const [startWeek, endWeek] = weekRange.split('-').map(s => s.trim());
										const startNum = weekMap[startWeek];
										const endNum = weekMap[endWeek];

										if (isDebugDate) {
											console.log(`  星期区间: ${startWeek}(${startNum}) 到 ${endWeek}(${endNum})`);
										}

										if (startNum <= endNum) {
											// 不跨周的情况
											if (day >= startNum && day <= endNum) {
												matchedPrice = spec.Price;
												matchedSpec = specName;
												if (isDebugDate) {
													console.log(`  ✓ 星期匹配成功! 价格: ${spec.Price}`);
												}
												break;
											}
										} else {
											// 跨周的情况，如周五-周一
											if (day >= startNum || day <= endNum) {
												matchedPrice = spec.Price;
												matchedSpec = specName;
												if (isDebugDate) {
													console.log(`  ✓ 星期匹配成功! 价格: ${spec.Price}`);
												}
												break;
											}
										}
									} else {
										// 单一星期，如：周五
										const weekName = weekRange.trim();
										if (weekMap[weekName] === day) {
											matchedPrice = spec.Price;
											matchedSpec = specName;
											if (isDebugDate) {
												console.log(`  ✓ 单一星期匹配成功! 价格: ${spec.Price}`);
											}
											break;
										}
									}
								} else if (isDebugDate) {
									console.log(`  ✗ 日期不在范围内`);
								}
							} else if (/^周[一二三四五六日]$/.test(specName)) {
								// 兼容旧的单一星期格式
								if (weekMap[specName] === day) {
									matchedPrice = spec.Price;
									matchedSpec = specName;
									if (isDebugDate) {
										console.log(`  ✓ 旧格式星期匹配成功! 价格: ${spec.Price}`);
									}
									break;
								}
							} else if (
								/^周[一二三四五六日]\s*-\s*周[一二三四五六日]$/.test(specName)
							) {
								// 兼容旧的星期区间格式
								const [start, end] = specName.split("-").map(s => s.trim());
								const startNum = weekMap[start];
								const endNum = weekMap[end];
								if (startNum <= endNum) {
									if (day >= startNum && day <= endNum) {
										matchedPrice = spec.Price;
										matchedSpec = specName;
										if (isDebugDate) {
											console.log(`  ✓ 旧格式星期区间匹配成功! 价格: ${spec.Price}`);
										}
										break;
									}
								} else {
									// 跨周区间，如周五-周一
									if (day >= startNum || day <= endNum) {
										matchedPrice = spec.Price;
										matchedSpec = specName;
										if (isDebugDate) {
											console.log(`  ✓ 旧格式跨周区间匹配成功! 价格: ${spec.Price}`);
										}
										break;
									}
								}
							}
						}
						
						if (isDebugDate) {
							console.log(`最终结果: 价格=${matchedPrice}, 匹配的spec=${matchedSpec}`);
							console.log('=== 调试结束 ===');
						}
						
						// 打印没有匹配上价格的日期
						if (matchedPrice === null) {
							console.log(`❌ 日期 ${date} (星期${day}) 没有匹配上任何价格规格`);
						}
						
						// 没有匹配到则为null
						const currentDateObj = new Date(date);
						const todayObj = new Date();
						todayObj.setHours(0, 0, 0, 0);
						currentDateObj.setHours(0, 0, 0, 0);
						const isPast = currentDateObj < todayObj;
						
						// 调试信息：如果价格匹配失败，记录详细信息
						// if (matchedPrice === null && date === '2025-08-31') {
						// 	console.log(`🔍 详细调试 - 日期: ${date}, 星期: ${day}`);
						// 	console.log(`🔍 所有规格检查完毕，最终结果: 价格=${matchedPrice}, 匹配的spec=${matchedSpec}`);
						// 	console.log(`🔍 当前日期对象:`, currentDateObj);
						// 	console.log(`🔍 今天对象:`, todayObj);
						// 	console.log(`🔍 是否过期:`, isPast);
						// }
						
						return {
							date,
							price: matchedPrice,
							info: matchedPrice ? "￥" + matchedPrice : null,
							disable: isPast ? true : !matchedPrice, // 当date小于今天时，disable为true，否则按原逻辑
							infoColor: "#6ac695",
						};
					});
				}

				// 应用排除日期规则（标记为disable）
				priceList.forEach(item => {
					if (excludeDates.has(item.date)) {
						item.disable = true;
					}
				});

				this.datePickerEnd = priceList[priceList.length - 1].date;
				this.priceList = priceList;

				if (
					this.type === 13 &&
					(!this.selectedSpecName || !this.selectedSpecName.includes("预约套餐"))
				) {
					const canSelectFirstDateIndex = this.priceList.findIndex(item => !item.disable);
					const canSelectFirstDate = this.priceList[canSelectFirstDateIndex]?.date;
					if (canSelectFirstDate) {
						const curDate = new Date(canSelectFirstDate);
						const newCurDate = this.getFormattedDate(curDate);
						curDate.setDate(curDate.getDate() + 1);
						const newNextDate = this.getFormattedDate(curDate);
						this.dateRange = [newCurDate, newNextDate]
						this.selectDate = [newCurDate]
					}
				}

				console.log("日历价格：", priceList);
			},
			// 初始化商品数据
			async init() {
				try {
					console.log("开始获取商品详情，ID:", this.id);
					const {
						Data
					} = await getGoodsDetail({
						Id: this.id,
					});
					console.log("获取到商品详情:", Data);

					this.hotelInfo.name = Data.Name;
					this.hotelInfo.price = Data.ShowPrice;
					this.hotelInfo.image = Data.Img;
					this.hotelInfo.businessId = Data.BusinessId;
					this.hotelInfo.productId = Data.Id || Data.ProductId;
					this.hotelInfo.productSpecId = Data.ProductSpecId;
					this.hotelInfo.bookingNotice = Data.BookingNotice;

					// 从商品名称中提取月份信息
					if (this.hotelInfo.name) {
						const monthMatch = this.hotelInfo.name.match(/（(\d+)月/);
						if (monthMatch) {
							const month = parseInt(monthMatch[1]);
							const currentYear = new Date().getFullYear();

							// 验证月份是否有效（1-12）
							if (month >= 1 && month <= 12) {
								// 计算该月的第一天
								const firstDay = new Date(currentYear, month - 1, 1);
								const firstDayStr = this.getFormattedDate(firstDay);

								// 计算该月的最后一天
								const lastDay = new Date(currentYear, month, 0);
								const lastDayStr = this.getFormattedDate(lastDay);

								console.log(`从商品名称提取到月份: ${month}月`);
								console.log(`该月第一天: ${firstDayStr}`);
								console.log(`该月最后一天: ${lastDayStr}`);

								// 更新日期选择器的范围
								this.datePickerStart = firstDayStr;
								this.datePickerEnd = lastDayStr;

								// 如果当前选择的日期不在该月范围内，重置为第一天
								const currentStartDate = new Date(this.dateRange[0]);
								const currentEndDate = new Date(this.dateRange[1]);

								// 判断当前选择的月份是否与提取的月份相同
								const currentMonth = currentStartDate.getMonth() + 1; // getMonth()返回0-11，需要+1

								if (currentMonth !== month) {
									// 计算第二天作为结束日期
									const secondDay = new Date(currentYear, month - 1, 2);
									const secondDayStr = this.getFormattedDate(secondDay);

									this.dateRange = [firstDayStr, secondDayStr];
									console.log(
										`当前选择月份(${currentMonth})与商品月份(${month})不同，重置日期范围为: ${firstDayStr} 到 ${secondDayStr}`
									);
								}
							}
						}
					}

					// 保存产品属性信息
					if (Data.ProductAttributes && Array.isArray(Data.ProductAttributes)) {
						console.log("商品有属性列表，数量:", Data.ProductAttributes.length);
						this.hotelInfo.ProductAttributes = Data.ProductAttributes;
					}

					// 保存场次信息
					if (Data.ProductSpecList && Array.isArray(Data.ProductSpecList)) {
						this.getCalendarPrices(Data.ProductSpecList);
						console.log("商品有规格列表，数量:", Data.ProductSpecList.length);
						this.hotelInfo.ProductSpecList = Data.ProductSpecList;

						// 如果有规格列表且不是门票或活动类型或不是酒店规格，默认选中第一个
						if (
							this.type !== 11 &&
							this.type !== 18 &&
							Data.ProductSpecList.length > 0
						) {
							let firstSpec = null;
							// this.hotelInfo.ProductSpecList.map((v) => {
							// 	if (!firstSpec && v.SpecName) {
							// 		let flag = this.dateRangeFlag(v.SpecName, this.dateRange);
							// 		if (flag) {
							// 			firstSpec = v;
							// 		}
							// 	}
							// });
							// firstSpec = firstSpec ? firstSpec : Data.ProductSpecList[0];
							firstSpec = firstSpec ? firstSpec : Data.ProductSpecList[0];
							this.selectedService = firstSpec.Id;

							// 更新产品ID和产品规格ID
							if (firstSpec.ProductId) {
								this.hotelInfo.productId = firstSpec.ProductId;
							}

							if (firstSpec.Id) {
								this.hotelInfo.productSpecId = firstSpec.Id;
							}

							// 如果有价格，更新价格
							if (firstSpec.Price) {
								this.hotelInfo.price = firstSpec.Price;
							}

							console.log(
								"默认选择的规格:",
								firstSpec.Name,
								"ID:",
								firstSpec.Id,
								"价格:",
								firstSpec.Price
							);
						}

						// 如果是门票或活动类型，在这里重新生成场次
						if (this.type === 11 || this.type === 18) {
							console.log("商品是门票或活动类型，立即重新生成场次信息");
							this.generateTimeSlots();
						}
					} else {
						console.log("商品无规格列表");
					}

					// 返回数据以便后续处理
					return Data;
				} catch (error) {
					console.error("获取商品详情失败:", error);
					uni.showToast({
						title: "获取商品信息失败",
						icon: "none",
					});
					return null;
				}
			},

			// 生成场次数据
			generateTimeSlots() {
				// 检查调用栈，确定是哪里调用了此方法
				console.log(
					"generateTimeSlots被调用，当前时间:",
					new Date().toLocaleTimeString()
				);

				// 检查商品和规格数据是否已经加载
				if (!this.hotelInfo) {
					console.error("hotelInfo未初始化，无法生成场次");
					return;
				}

				// 检查是否有场次数据
				if (
					!this.hotelInfo.ProductSpecList ||
					!Array.isArray(this.hotelInfo.ProductSpecList)
				) {
					console.warn("无场次数据或非数组格式:", this.hotelInfo.ProductSpecList);
					this.timeSlots = [{
						id: null,
						startTime: "暂无场次信息",
						endTime: "",
						price: this.hotelInfo.price,
						available: false,
						productId: this.hotelInfo.productId,
						productSpecId: null,
					}, ];
					return;
				}

				if (this.hotelInfo.ProductSpecList.length === 0) {
					console.warn("规格列表为空数组");
					this.timeSlots = [{
						id: null,
						startTime: "暂无场次配置",
						endTime: "",
						price: this.hotelInfo.price,
						available: false,
						productId: this.hotelInfo.productId,
						productSpecId: null,
					}, ];
					return;
				}

				// 将对象转为字符串，但限制长度避免日志过长
				const specListStr = JSON.stringify(
					this.hotelInfo.ProductSpecList
				).substring(0, 500);
				console.log(
					"原始规则数据(前500字符):",
					specListStr + (specListStr.length >= 500 ? "..." : "")
				);

				// 当前日期和时间
				const currentDate = new Date();
				const today = this.getFormattedDate(currentDate);
				const currentTimeInMinutes =
					currentDate.getHours() * 60 + currentDate.getMinutes();

				console.log("当前时间(分钟):", currentTimeInMinutes, "当前日期:", today);

				// 选择的日期
				const selectedDate = this.ticketDate;
				const isToday = today === selectedDate;

				console.log("选择的日期:", selectedDate, "是否为今天:", isToday);

				// 将时间字符串转换为分钟数
				const timeToMinutes = (timeStr) => {
					if (!timeStr) return 0;
					const [hours, minutes] = timeStr.split(":").map(Number);
					return hours * 60 + (minutes || 0);
				};

				// 格式化时间，从HH:MM:SS转为HH:MM
				const formatTimeString = (timeStr) => {
					if (!timeStr || timeStr === "全天可用") return timeStr;
					const parts = timeStr.split(":");
					if (parts.length >= 2) {
						return `${parts[0]}:${parts[1]}`;
					}
					return timeStr;
				};

				// 判断选择的日期是星期几 (1-7，1是周一，7是周日)
				const selectedDateObj = new Date(selectedDate);
				const selectedDay = selectedDateObj.getDay();
				const selectedOpenTypeDay = selectedDay === 0 ? 7 : selectedDay;

				console.log(
					"选择的星期:",
					selectedDay,
					"转换后的OpenType星期:",
					selectedOpenTypeDay
				);

				// 1. 筛选符合用户选择日期的规则
				const validRules = [];

				for (const rule of this.hotelInfo.ProductSpecList) {
					// 初始化规则有效性为true
					let isRuleValid = true;

					// 检查日期范围
					if (rule.StartDate) {
						const startDate = new Date(rule.StartDate);
						startDate.setHours(0, 0, 0, 0);

						if (selectedDateObj < startDate) {
							console.log(
								`规则ID ${rule.Id} 不符合开始日期条件, 规则开始日期: ${rule.StartDate}`
							);
							isRuleValid = false;
						}
					}

					if (isRuleValid && rule.EndDate) {
						const endDate = new Date(rule.EndDate);
						endDate.setHours(0, 0, 0, 0);

						if (selectedDateObj > endDate) {
							console.log(
								`规则ID ${rule.Id} 不符合结束日期条件, 规则结束日期: ${rule.EndDate}`
							);
							isRuleValid = false;
						}
					}

					// 检查星期限制
					if (isRuleValid && rule.OpenType) {
						const openDaysStr = rule.OpenType.split(",").map((d) => d.trim());
						// 检查是否包含8，如果包含则表示一周7天都开放
						if (openDaysStr.includes("8")) {
							console.log(`规则ID ${rule.Id} 包含OpenType=8，表示一周7天都开放`);
							// 一周7天都开放，不需要进一步检查
						} else {
							// 常规处理，检查当前星期是否在开放列表中
							const openDays = openDaysStr.map((d) => parseInt(d));
							if (!openDays.includes(selectedOpenTypeDay)) {
								console.log(
									`规则ID ${rule.Id} 不符合星期限制, 规则开放日: ${rule.OpenType}, 当前星期: ${selectedOpenTypeDay}`
								);
								isRuleValid = false;
							}
						}
					}

					// 如果规则有效，添加到符合条件的规则列表
					if (isRuleValid) {
						validRules.push(rule);
					}
				}

				console.log(`找到 ${validRules.length} 条符合当前日期的规则`);

				// 如果没有符合条件的规则，显示无可用场次
				if (validRules.length === 0) {
					this.timeSlots = [{
						id: null,
						startTime: "暂无可用场次",
						endTime: "",
						price: this.hotelInfo.price,
						available: false,
						productId: this.hotelInfo.productId,
						productSpecId: null,
					}, ];

					uni.showToast({
						title: "所选日期无可用场次",
						icon: "none",
						duration: 2000,
					});
					return;
				}

				// 2. 按Sort值从小到大排序
				validRules.sort((a, b) => {
					const sortA = typeof a.Sort === "number" ? a.Sort : 999;
					const sortB = typeof b.Sort === "number" ? b.Sort : 999;
					return sortA - sortB;
				});

				// 3. 选择Sort值最小的规则
				const bestRule = validRules[0];
				console.log(
					`选择Sort值最小的规则: ID=${bestRule.Id}, Sort=${
          bestRule.Sort || "未设置"
        }`
				);

				// 4. 处理场次数据
				let timeSlotData = [];

				// 检查是否有TicketSceneTimeList
				if (
					bestRule.TicketSceneTimeList &&
					Array.isArray(bestRule.TicketSceneTimeList) &&
					bestRule.TicketSceneTimeList.length > 0
				) {
					console.log(
						"使用TicketSceneTimeList作为场次数据，场次数量:",
						bestRule.TicketSceneTimeList.length
					);

					// 使用TicketSceneTimeList作为场次数据，并检查是否可购买
					timeSlotData = bestRule.TicketSceneTimeList.map((scene) => {
						// 计算开始和结束时间(分钟)
						let startTimeInMinutes = 0;
						let endTimeInMinutes = 24 * 60 - 1; // 默认为全天

						if (scene.StartTime) {
							startTimeInMinutes = timeToMinutes(scene.StartTime);
						}

						if (scene.EndTime) {
							endTimeInMinutes = timeToMinutes(scene.EndTime);
						}

						// 判断是否可购买
						let isAvailable = true;

						if (isToday) {
							// 如果场次已经结束，不可购买
							if (currentTimeInMinutes >= endTimeInMinutes) {
								isAvailable = false;
							}
							// 如果距离结束不足1小时，不可购买
							else if (currentTimeInMinutes > endTimeInMinutes - 60) {
								isAvailable = false;
							}
						}

						console.log(
							`处理场次: ${formatTimeString(
              scene.StartTime || "00:00"
            )} - ${formatTimeString(
              scene.EndTime || "23:59"
            )}, 可用: ${isAvailable}`
						);

						return {
							id: scene.Id || bestRule.Id,
							startTime: formatTimeString(scene.StartTime) || "00:00",
							endTime: formatTimeString(scene.EndTime) || "23:59",
							price: scene.Price || bestRule.Price || this.hotelInfo.price,
							available: isAvailable,
							productId: bestRule.ProductId || this.hotelInfo.productId,
							productSpecId: bestRule.Id,
							sceneId: scene.Id, // 保存场次ID
							ruleName: bestRule.Name || "", // 保存规则名称
						};
					});
				} else if (bestRule.StartTime || bestRule.EndTime) {
					// 使用规则本身的StartTime和EndTime作为场次时间
					console.log("使用规则StartTime/EndTime作为场次数据");

					// 计算开始和结束时间(分钟)
					let startTimeInMinutes = 0;
					let endTimeInMinutes = 24 * 60 - 1; // 默认为全天

					if (bestRule.StartTime) {
						startTimeInMinutes = timeToMinutes(bestRule.StartTime);
					}

					if (bestRule.EndTime) {
						endTimeInMinutes = timeToMinutes(bestRule.EndTime);
					}

					// 判断是否可购买
					let isAvailable = true;

					if (isToday) {
						// 如果场次已经结束，不可购买
						if (currentTimeInMinutes >= endTimeInMinutes) {
							isAvailable = false;
						}
						// 如果距离结束不足1小时，不可购买
						else if (currentTimeInMinutes > endTimeInMinutes - 60) {
							isAvailable = false;
						}
					}

					console.log(
						`处理单场次: ${formatTimeString(
            bestRule.StartTime || "00:00"
          )} - ${formatTimeString(
            bestRule.EndTime || "23:59"
          )}, 可用: ${isAvailable}`
					);

					timeSlotData = [{
						id: bestRule.Id,
						startTime: formatTimeString(bestRule.StartTime) || "00:00",
						endTime: formatTimeString(bestRule.EndTime) || "23:59",
						price: bestRule.Price || this.hotelInfo.price,
						available: isAvailable,
						productId: bestRule.ProductId || this.hotelInfo.productId,
						productSpecId: bestRule.Id,
						ruleName: bestRule.Name || "", // 保存规则名称
					}, ];
				} else {
					// 没有可用的场次时间
					console.log("规则中没有可用的场次时间信息");
					timeSlotData = [{
						id: bestRule.Id,
						startTime: "全天可用",
						endTime: "",
						price: bestRule.Price || this.hotelInfo.price,
						available: true,
						productId: bestRule.ProductId || this.hotelInfo.productId,
						productSpecId: bestRule.Id,
						ruleName: bestRule.Name || "", // 保存规则名称
					}, ];
				}

				console.log(
					"场次数量:",
					timeSlotData.length,
					"其中可购买:",
					timeSlotData.filter((s) => s.available).length
				);

				// 5. 检查是否有可购买的场次
				const hasAvailableSlots = timeSlotData.some((slot) => slot.available);

				// 6. 如果没有任何场次或所有场次都不可购买，添加一个提示性的场次
				if (timeSlotData.length === 0) {
					console.log("当天无场次，添加提示性场次");
					this.timeSlots = [{
						id: null,
						startTime: "暂无可用场次",
						endTime: "",
						price: this.hotelInfo.price,
						available: false,
						productId: this.hotelInfo.productId,
						productSpecId: null,
					}, ];

					// 提示用户
					uni.showToast({
						title: isToday ? "今日已无可用场次" : "所选日期无可用场次",
						icon: "none",
						duration: 2000,
					});
				} else {
					// 7. 更新场次列表 - 所有场次都显示，包括不可购买的
					this.timeSlots = timeSlotData;

					// 如果有可购买的场次，但没有可购买的场次被选中，选择第一个可购买的场次
					if (
						hasAvailableSlots &&
						!this.timeSlots[this.selectedTimeSlot]?.available
					) {
						const firstAvailableIndex = this.timeSlots.findIndex(
							(slot) => slot.available
						);
						if (firstAvailableIndex !== -1) {
							this.selectedTimeSlot = firstAvailableIndex;
						}
					}
				}
			},

			// 选择门票场次
			selectTimeSlot(index) {
				// 检查场次是否可用
				if (!this.timeSlots[index].available) {
					uni.showToast({
						title: "该场次剩余时间不足1小时",
						icon: "none",
						duration: 2000,
					});
					return;
				}

				this.selectedTimeSlot = index;
				// 更新价格（如果场次价格不同）
				if (this.timeSlots[index].price !== this.hotelInfo.price) {
					this.hotelInfo.price = this.timeSlots[index].price;
				}
			},

			// 门票日期变更
			onTicketDateChange(date) {
				this.ticketDate = date;
				// 根据日期重新获取场次信息
				this.generateTimeSlots();
				this.selectedTimeSlot = 0;
			},

			// 获取用户优惠券
			async getCoupon() {
				try {
					const {
						Data
					} = await GetUserCoupons({
						Index: 1,
						Size: 100,
						BusinessId: this.hotelInfo.businessId,
						CouponStatus: 1,
					});

					if (!Data || !Array.isArray(Data)) {
						console.warn("获取优惠券返回数据格式异常");
						this.hasCoupons = false;
						return;
					}

					const currentDate = Date.now();

					// 筛选有效优惠券
					const validCoupons = Data.filter((coupon) => {
						const startTime = Date.parse(coupon.EffectStartDatetime);
						const endTime = Date.parse(coupon.EffectEndDatetime);
						return currentDate < endTime && currentDate > startTime;
					});

					// 设置是否有可用优惠券
					this.hasCoupons = validCoupons.length > 0;
				} catch (error) {
					console.error("获取优惠券失败:", error);
					this.hasCoupons = false;
				}
			},

			// 跳转到优惠券选择页面
			navigateToCoupons() {
				// 准备传递的参数
				const params = {
					businessId: this.hotelInfo.businessId,
					totalPrice: this.totalPrice,
					productId: this.hotelInfo.productId,
					selectedCoupons: this.useCoupons || [], // 传递已选择的优惠券
				};

				// 跳转到优惠券页面
				uni.navigateTo({
					url: "/mall_subpages/goods/coupons?params=" +
						encodeURIComponent(JSON.stringify(params)),
				});
			},

			// 从优惠券页面返回时接收数据
			onCouponSelected(coupons) {
				// 记录当前价格作为起始值
				this.lastTotalPrice = this.totalPrice;

				this.useCoupons = coupons || [];

				// 计算优惠券总折扣金额
				this.calculateCouponDiscount();

				// 需要手动刷新countTo组件
				this.$nextTick(() => {
					if (this.$refs.countTo) {
						this.$refs.countTo.start();
					}
				});
			},

			// 计算优惠券总折扣金额
			calculateCouponDiscount() {
				if (!this.useCoupons || this.useCoupons.length === 0) {
					this.couponTotalDiscount = 0;
					return;
				}

				let totalDiscount = 0;
				const originalPrice = parseFloat(this.totalPrice);

				this.useCoupons.forEach((coupon) => {
					if (coupon.CouponTemple && coupon.CouponTemple.FullReduceAmount) {
						totalDiscount += parseFloat(coupon.CouponTemple.FullReduceAmount);
					}
				});

				// 确保折扣不超过总价
				this.couponTotalDiscount = Math.min(totalDiscount, originalPrice);
			},

			// 构建优惠券参数
			buildCouponParams() {
				if (!this.useCoupons || this.useCoupons.length === 0) {
					return [];
				}

				return this.useCoupons.map((coupon) => ({
					CouponCode: coupon.CouponCode,
					BusinessId: coupon.BusinessIds ? this.hotelInfo.businessId : 0,
				}));
			},

			// 获取格式化的日期字符串 YYYY-MM-DD
			getFormattedDate(date) {
				const year = date.getFullYear();
				const month = String(date.getMonth() + 1).padStart(2, "0");
				const day = String(date.getDate()).padStart(2, "0");
				return `${year}-${month}-${day}`;
			},

			// 获取明天的日期对象
			getTomorrowDate() {
				const date = new Date();
				date.setDate(date.getDate() + 1);
				return date;
			},

			// 获取指定天数后的日期对象
			getDateAfterDays(days) {
				const date = new Date();
				date.setDate(date.getDate() + days);
				return date;
			},

			// 减少数量
			decreaseRoom() {
				if (this.roomNum > 1) {
					// 记录当前价格作为起始值
					this.lastTotalPrice = this.totalPrice;
					this.roomNum--;

					// 需要手动刷新countTo组件
					this.$nextTick(() => {
						if (this.$refs.countTo) {
							this.$refs.countTo.start();
						}
					});
				}
			},

			// 增加数量
			increaseRoom() {
				// 记录当前价格作为起始值
				this.lastTotalPrice = this.totalPrice;
				this.roomNum++;

				// 需要手动刷新countTo组件
				this.$nextTick(() => {
					if (this.$refs.countTo) {
						this.$refs.countTo.start();
					}
				});
			},

			// 用户选择相关方法
			openUserSelector() {
				this.currentSelectedGuests = [...this.guests];
				this.$refs.userSelector.open();

				// 打开时主动刷新一次数据
				setTimeout(() => {
					if (this.$refs.userSelector.$vm) {
						this.$refs.userSelector.$vm.init();
					}
				}, 300);
			},

			closeUserSelector() {
				this.$refs.userSelector.close();
			},

			onClearSelection() {
				this.guests = [];
			},

			onSelectComplete() {
				this.closeUserSelector();
			},

			onUserSelected(userData) {
				const existingIndex = this.guests.findIndex(
					(guest) => guest.idCard === userData.idCard
				);

				if (existingIndex === -1) {
					this.guests.push(userData);
				}
			},

			removeGuest(index) {
				this.guests.splice(index, 1);
			},

			// 打开地址选择器
			openAddressSelector() {
				this.$refs.addressSelector.open();

				// 打开时主动刷新一次数据
				setTimeout(() => {
					if (this.$refs.addressSelector.$vm) {
						this.$refs.addressSelector.$vm.init();
					}
				}, 300);
			},

			// 关闭地址选择器
			closeAddressSelector() {
				this.$refs.addressSelector.close();
			},

			// 地址选择完成
			onAddressSelected(address) {
				this.selectedAddress = address;
				console.log("选择的地址:", address);
			},

			// 地址选择完成关闭弹窗
			onAddressSelectComplete() {
				this.closeAddressSelector();
			},

			// 验证订单数据
			validateOrderData() {
				// 验证入住人数量 - 酒店、门票和活动需要验证
				if (
					([3, 11, 13, 15, 18].includes(this.type)) &&
					this.guests.length === 0
				) {
					let tipText = this.$t("order.guestInfo.atLeastOne");
					if (this.type === 13) {
						tipText += this.$t("order.guestInfo.checkInPerson");
					} else if ([3, 11, 15].includes(this.type)) {
						tipText += this.$t("order.guestInfo.tourist");
					} else if (this.type === 18) {
						tipText += this.$t("order.guestInfo.participant");
					}

					uni.showToast({
						title: tipText,
						icon: "none",
					});
					return false;
				}

				// 验证入住人数量是否与房间数量匹配 - 仅酒店需要验证
				if (this.type === 13 && this.guests.length < this.roomNum) {
					uni.showToast({
						title: this.$t("order.guestInfo.roomCountMismatch", {
							count: this.roomNum,
						}),
						icon: "none",
						duration: 2500,
					});
					return false;
				}

				// 验证活动参与人数是否与名额匹配
				if (this.type === 18 && this.guests.length < this.roomNum) {
					uni.showToast({
						title: this.$t("order.guestInfo.quotaMismatch", {
							count: this.roomNum,
						}),
						icon: "none",
						duration: 2500,
					});
					return false;
				}

				// 验证实物商品是否选择了收货地址
				if (this.type === 2 && !this.selectedAddress) {
					uni.showToast({
						title: this.$t("order.selectAddress"),
						icon: "none",
					});
					return false;
				}

				// 检查必要的商品信息是否存在
				if (!this.hotelInfo.businessId || !this.hotelInfo.productId) {
					uni.showToast({
						title: "商品信息不完整",
						icon: "none",
					});
					return false;
				}

				return true;
			},

			// 构建订单参数
			buildOrderParams() {
				// 构建预订表单参数
				const type = Number(this.type); // 使用页面传入的类型，而不是从hotelInfo中获取
				const selectedSlot = this.timeSlots[this.selectedTimeSlot];

				// 记录选中的场次信息，用于调试
				console.log("选中的场次信息:", JSON.stringify(selectedSlot));
				console.log("游客/入住人信息:", JSON.stringify(this.guests));
				console.log("当前产品类型:", type);

				const orderParams = {
					// 基础订单信息
					ProductId: this.hotelInfo.productId,
					ProductName: this.hotelInfo.name,
					ProductType: type,
					Price: selectedSlot ? selectedSlot.price : this.hotelInfo.price,
					PayStatus: 0,
					Point: 0,
					Count: Number(this.roomNum),
					Deposit: 0,
					ContactMobile: this.contact ? this.contact.phone : "",
					ContactName: this.contact ? this.contact.name : "",
					CouponDiscount: 0,
					OriginalPrice: this.hotelInfo.price,
					PlatformType: 20, // 小程序
					SettleType: 1,
					payType: 0,
					IsTicket: 1, // 电子票
					ShopId: this.hotelInfo.shopId || 0,
					MerchantId: this.hotelInfo.MerchantID || 0,
					OrderRemak: this.remark || "",
					BusinessId: this.hotelInfo.businessId || 0,
					Persons: [],
				};

				// 所有类型都处理游客/入住人信息，不区分类型
				if (this.guests && this.guests.length > 0) {
					orderParams.Persons = this.guests.map((item) => ({
						Name: item.name,
						Mobile: item.phone || "",
						IDCard: item.idCard,
					}));

					console.log(
						"添加游客/入住人信息到订单:",
						orderParams.Persons.length,
						"人"
					);
				}

				// 根据不同的产品类型添加特定参数
				if (type === 11 || type === 18) {
					// 门票类型或活动类型
					// 获取选中场次的productSpecId，如果存在则使用，否则使用默认值
					const productSpecId =
						selectedSlot && selectedSlot.productSpecId ?
						selectedSlot.productSpecId :
						this.hotelInfo.productSpecId;

					console.log("使用的productSpecId:", productSpecId);

					// 扩展门票相关字段
					Object.assign(orderParams, {
						ProductSpecId: productSpecId,
						TicketDate: this.ticketDate,
						OrderStartDate: this.ticketDate,
						TicketStartTime: selectedSlot ? selectedSlot.startTime : "",
						TicketEndTime: selectedSlot ? selectedSlot.endTime : "",
					});

					// 如果存在场次ID，也添加到订单参数中
					if (selectedSlot && selectedSlot.sceneId) {
						orderParams.SceneId = selectedSlot.sceneId;
						console.log("添加场次ID到订单:", selectedSlot.sceneId);
					}
				} else if (type === 10 || type === 13) {
					// 酒店类型
					// 获取ProductSpecId，如果有选择具体服务，使用选择的服务ID
					const productSpecId =
						this.selectedService || this.hotelInfo.productSpecId;

					console.log("酒店类型使用的ProductSpecId:", productSpecId);

					Object.assign(orderParams, {
						ProductSpecId: productSpecId, // 添加ProductSpecId参数
						StartTime: this.dateRange[0],
						OrderStartDate: this.dateRange[0],
						EndTime: this.dateRange[1],
						OrderEndDate: this.dateRange[1],
						Days: this.isReservation ? 1 : Number(this.nightsCount),
						RoomCount: this.roomNum,
					});
				} else if (type === 2) {
					// 线上实物商品
					// 获取ProductSpecId
					const productSpecId =
						this.selectedService || this.hotelInfo.productSpecId;

					console.log("线上商品使用的ProductSpecId:", productSpecId);

					// 添加收货地址信息
					if (this.selectedAddress) {
						Object.assign(orderParams, {
							ProductSpecId: productSpecId,
							Address: this.selectedAddress.address,
							City: this.selectedAddress.city,
							County: this.selectedAddress.county,
							Province: this.selectedAddress.province,
							Mobile: this.selectedAddress.phone,
							Name: this.selectedAddress.name,
							AddressId: this.selectedAddress.id,
						});

						console.log("添加收货地址信息到订单");
					}
				} else {
					// 其他产品类型的特殊处理
					console.log("其他产品类型:", type);

					// 获取ProductSpecId
					const productSpecId =
						this.selectedService || this.hotelInfo.productSpecId;

					console.log("其他类型使用的ProductSpecId:", productSpecId);

					// 为其他类型商品也添加ProductSpecId
					Object.assign(orderParams, {
						ProductSpecId: productSpecId,
					});
				}

				console.log("构建的订单参数:", JSON.stringify(orderParams));
				return orderParams;
			},

			// 选择其他服务
			selectService(service, isJudge = true) {

				// console.log("service =>", service);
				// console.log("dateRange =>", this.dateRange);
				// const flag = isJudge ?
				// 	this.dateRangeFlag(service.SpecName, this.dateRange) :
				// 	true;
				// // console.log("当前选择的规格是否符合当前选择的日期=>", flag);
				// if (!flag) {
				// 	uni.showToast({
				// 		title: "当前选择的规格与住宿时间不匹配",
				// 		icon: "none",
				// 	});
				// 	return;
				// }

				// 记录当前价格作为起始值
				this.lastTotalPrice = this.totalPrice;

				this.selectedService = service.Id;

				// 更新产品ID和产品规格ID
				if (service) {
					if (service.ProductId) {
						this.hotelInfo.productId = service.ProductId;
					}

					if (service.Id) {
						this.hotelInfo.productSpecId = service.Id;
					}

					// 更新价格
					if (service.Price !== undefined && service.Price !== null) {
						this.hotelInfo.price = service.Price;
					}

					console.log(
						"选择了服务:",
						service.Name,
						"ID:",
						service.Id,
						"价格:",
						service.Price
					);
					// 需要手动刷新countTo组件
					this.$nextTick(() => {
						if (this.$refs.countTo) {
							this.$refs.countTo.start();
						}
					});
				}
			},

			// 提交订单
			async submitOrder() {
				// 防重复提交
				if (this.isSubmitting) {
					uni.showToast({
						title: this.$t("order.submitting"),
						icon: "none",
					});
					return;
				}
				if (!this.checked) {
					uni.showToast({
						icon: "none",
						title: "请先勾选同意协议",
					});
					return;
				}
				// 验证订单数据
				if (!this.validateOrderData()) {
					return;
				}

				if (this.isPointsPayment) {
					const diffPoints = this.userPoints - this.totalPoints;
					if (diffPoints < 0) {
						const title = `积分不足，所需积分：${this.totalPoints}，当前可用积分：${this.userPoints}。`;
						uni.showToast({
							title,
							icon: "none",
						});
						return;
					}
				}

				// 设置提交状态
				this.isSubmitting = true;

				// 显示加载提示
				uni.showLoading({
					title: "提交中...",
					mask: true,
				});

				try {
					// 构建订单参数
					const params = this.buildOrderParams();

					// 构建优惠券参数 - 只在非积分支付模式下添加
					const useCoupons = this.isPointsPayment ? [] : this.buildCouponParams();

					// 获取选中的场次信息，用于订单提交
					if (this.type === 11 && this.timeSlots.length > 0) {
						const selectedSlot = this.timeSlots[this.selectedTimeSlot];
						console.log("选中场次信息:", selectedSlot);

						// 确保选中场次的productSpecId和sceneId被正确使用
						if (params.ProductSpecId !== selectedSlot.productSpecId) {
							console.log(
								`修正ProductSpecId: 从${params.ProductSpecId}改为${selectedSlot.productSpecId}`
							);
							params.ProductSpecId = selectedSlot.productSpecId;
						}

						if (selectedSlot.sceneId && !params.SceneId) {
							console.log(`添加SceneId: ${selectedSlot.sceneId}`);
							params.SceneId = selectedSlot.sceneId;
						}

						// 添加使用时间
						params.SlotTime = `${selectedSlot.startTime}-${selectedSlot.endTime}`;
						console.log(`添加SlotTime: ${params.SlotTime}`);
					}

					// 组装最终请求参数
					const requestParams = {
						Coupons: useCoupons,
						Message: this.hotelInfo.name,
					};

					if (this.type === 1 || this.type === 2) {
						requestParams.OrdersProductList = [params];
						requestParams.City = params.City;
						requestParams.County = params.County;
						requestParams.Mobile = params.Mobile;
						requestParams.Name = params.Name;
						requestParams.Province = params.Province;
						requestParams.Address = params.Address;
					} else if (
						this.type === 13 &&
						this.selectedSpecName &&
						this.selectedSpecName.includes("预约套餐")
					) {
						// 预约套餐，仍然用原来的单一订单入参方式
						requestParams.OrderProductList = [params];
						requestParams.City = params.City;
						requestParams.County = params.County;
						requestParams.Mobile = params.Mobile;
						requestParams.Name = params.Name;
						requestParams.Province = params.Province;
						requestParams.Address = params.Address;
					} else if (this.type === 13) {
						// 酒店类型：每一天一个子订单
						const orders = [];
						
						if (
							this.dateRange &&
							this.dateRange.length === 2 &&
							this.priceList &&
							this.priceList.length > 0
						) {
							const start = new Date(this.dateRange[0]);
							const end = new Date(this.dateRange[1]);
							console.log("selectDate ===>",this.selectDate);
							this.selectDate.map(dateStr=>{
							
							// for (let d = new Date(start); d < end; d.setDate(d.getDate() + 1)) {
								// const dateStr = d;
								const d = new Date(dateStr)
								console.log("dateStr =========>",dateStr);
								var priceObj = this.priceList.find((p) => p.date === dateStr);
								var dayPrice =
									priceObj && priceObj.price != null ?
									priceObj.price :
									this.hotelInfo.price;
								// 匹配规格
								let matchedSpec = null;
								if (
									this.hotelInfo.ProductSpecList &&
									this.hotelInfo.ProductSpecList.length > 0
								) {
									var day = d.getDay();
									var currentDate = new Date(dateStr);
									var weekMap = {
										周日: 0,
										周一: 1,
										周二: 2,
										周三: 3,
										周四: 4,
										周五: 5,
										周六: 6,
									};
									for (var spec of this.hotelInfo.ProductSpecList) {
										if (!spec.SpecName) continue;
										var specName = spec.SpecName.trim();
							
										// 解析新的SpecName格式：'2025/07/01-2025/08-01&周五-周六'
										if (specName.includes('&')) {
											var [dateRangeStr, weekRange] = specName.split('&');
							
											// 解析日期范围
											var [startDateStr, endDateStr] = dateRangeStr.split('-');
											var startDate = new Date(startDateStr);
											var endDate = new Date(endDateStr);
							
											// 检查当前日期是否在日期范围内
											if (currentDate >= startDate && currentDate <= endDate) {
												// 解析星期范围
												if (weekRange.includes('-')) {
													// 星期区间，如：周五-周六
													var [startWeek, endWeek] = weekRange.split('-').map(s => s
														.trim());
													var startNum = weekMap[startWeek];
													var endNum = weekMap[endWeek];
							
													if (startNum <= endNum) {
														// 不跨周的情况
														if (day >= startNum && day <= endNum) {
															matchedSpec = spec;
															break;
														}
													} else {
														// 跨周的情况，如周五-周一
														if (day >= startNum || day <= endNum) {
															matchedSpec = spec;
															break;
														}
													}
												} else {
													// 单一星期，如：周五
													var weekName = weekRange.trim();
													if (weekMap[weekName] === day) {
														matchedSpec = spec;
														break;
													}
												}
											}
										} else if (/^周[一二三四五六日]$/.test(specName)) {
											// 兼容旧的单一星期格式
											if (weekMap[specName] === day) {
												matchedSpec = spec;
												break;
											}
										} else if (
											/^周[一二三四五六日]\s*-\s*周[一二三四五六日]$/.test(
												specName
											)
										) {
											// 兼容旧的星期区间格式
											var [startW, endW] = specName
												.split("-")
												.map((s) => s.trim());
											var startNum = weekMap[startW];
											var endNum = weekMap[endW];
											if (startNum <= endNum) {
												if (day >= startNum && day <= endNum) {
													matchedSpec = spec;
													break;
												}
											} else {
												if (day >= startNum || day <= endNum) {
													matchedSpec = spec;
													break;
												}
											}
										}
									}
								}
								orders.push({
									ProductId: matchedSpec && matchedSpec.ProductId ?
										matchedSpec.ProductId : this.hotelInfo.productId,
									ProductName: this.hotelInfo.name,
									ProductType: 13,
									Price: dayPrice,
									PayStatus: 0,
									Point: 0,
									Count: Number(this.roomNum),
									Deposit: 0,
									ContactMobile: this.contact ? this.contact.phone : "",
									ContactName: this.contact ? this.contact.name : "",
									CouponDiscount: 0,
									OriginalPrice: this.hotelInfo.price,
									PlatformType: 20,
									SettleType: 1,
									payType: 0,
									IsTicket: 1,
									ShopId: this.hotelInfo.shopId || 0,
									MerchantId: this.hotelInfo.MerchantID || 0,
									OrderRemak: this.remark || "",
									BusinessId: this.hotelInfo.businessId || 0,
									Persons: this.guests && this.guests.length > 0 ?
										this.guests.map((item) => ({
											Name: item.name,
											Mobile: item.phone || "",
											IDCard: item.idCard,
										})) : [],
									ProductSpecId: matchedSpec && matchedSpec.Id ?
										matchedSpec.Id : this.hotelInfo.productSpecId,
									StartTime: dateStr,
									OrderStartDate: dateStr,
									EndTime: this.getFormattedDate(
										new Date(new Date(dateStr).getTime() + 24 * 60 * 60 * 1000)
									),
									OrderEndDate: this.getFormattedDate(
										new Date(new Date(dateStr).getTime() + 24 * 60 * 60 * 1000)
									),
									Days: 1,
									RoomCount: this.roomNum,
								});
							// }
							})
						}
						requestParams.OrderProductList = orders;
						// 这里可根据需要补充requestParams的其他字段
					} else {
						requestParams.OrderProductList = [params];
						requestParams.City = params.City;
						requestParams.County = params.County;
						requestParams.Mobile = params.Mobile;
						requestParams.Name = params.Name;
						requestParams.Province = params.Province;
						requestParams.Address = params.Address;
					}

					// 如果是积分支付类型，添加UsePoints参数
					if (this.isPointsPayment) {
						requestParams.UsePoints = true;
					}

					console.log("提交订单参数:", JSON.stringify(requestParams));

					// 判断商品类型调用对应API
					let apiResult;
					if (this.type === 17) {
						// 套餐类型使用packageProductOrders
						const {
							Data
						} = await addPackProductOrders(requestParams);
						apiResult = Data;
					} else if (this.type === 1 || this.type === 2) {
						// 其他类型使用通用接口
						const {
							Data
						} = await addProductOrders(requestParams);
						apiResult = Data;
					} else {
						// 其他类型使用通用接口
						const {
							Data
						} = await addEleCouponOrders(requestParams);
						apiResult = Data;
					}

					// 隐藏加载提示
					uni.hideLoading();

					console.log("订单提交结果:", apiResult);

					if (!apiResult || !apiResult.OrdersOnLineId) {
						uni.showToast({
							title: this.$t("order.submitFailed"),
							icon: "none",
							duration: 2000,
						});
						return;
					}

					// 判断是积分支付或支付金额为0，直接跳转到成功页面
					if (this.isPointsPayment || this.totalPrice === 0) {
						uni.redirectTo({
							url: `/mall_subpages/goods/success?id=${apiResult.OrdersOnLineId}&delta=1&integral=${this.isPointsPayment}`,
						});
					} else {
						// 跳转到支付页面，只传递OrdersOnLineId作为id参数
						uni.redirectTo({
							url: `/mall_subpages/goods/payment?id=${apiResult.OrdersOnLineId}&delta=2`,
						});
					}
				} catch (error) {
					console.log("error =>",error);
					uni.hideLoading();
					uni.showToast({
						title: error.Msg || "提交订单失败",
						icon: "none",
						duration: 2000,
					});
				} finally {
					// 延迟重置提交状态，防止快速重复点击
					setTimeout(() => {
						this.isSubmitting = false;
					}, 2000);
				}
			},

			// 日期选择变更
			onDateChange(e) {
				console.log("e=>", e);
				let value = [e.range.before, e.range.after];
				let selectDate = e.range.data; //所选日期数组
				console.log("onDateChange =>", value);
				if (!value || value.length < 2 || !value[0] || !value[1] || value[0] === "" || value[1] === "") return;
				// 检查是否选择了过去的日期
				const today = new Date();
				today.setHours(0, 0, 0, 0); // 将时间设置为当天的开始
				const startDate = new Date(value[0]);

				// 如果选择了过去的日期
				if (startDate < today) {
					// const todayFormatted = this.getFormattedDate(today);
					// // 计算明天日期
					// const tomorrowDate = new Date(today);
					// tomorrowDate.setDate(today.getDate() + 1);
					// const tomorrowFormatted = this.getFormattedDate(tomorrowDate);
					// // 更新日期范围并提示用户
					// this.dateRange = [todayFormatted, tomorrowFormatted];
					uni.showToast({
						title: this.$t("order.pastDateError"),
						icon: "none",
						duration: 2000,
					});
					return;
				}
				// 检查开始日期和结束日期是否相同
				if (value[0] === value[1]) {
					// 如果相同，则将结束日期设置为开始日期的后一天
					const nextDay = new Date(startDate);
					nextDay.setDate(nextDay.getDate() + 1);
					const nextDayFormatted = this.getFormattedDate(nextDay);
					// 更新日期范围
					this.dateRange = [value[0], nextDayFormatted];
					// 提示用户
					uni.showToast({
						title: this.$t("order.sameDateError"),
						icon: "none",
						duration: 2000,
					});
					return;
				}

				// 新增日期有效性验证
				const start = new Date(value[0]);
				const end = new Date(value[1]);
				const timeDiff = end.getTime() - start.getTime();
				const dayDiff = Math.ceil(timeDiff / (1000 * 3600 * 24));

				if (selectDate.length !== dayDiff + 1) {
					uni.showToast({
						title: "住房日期中存在不可选日期",
						icon: "none",
						duration: 3000
					});
				}

				// 日期合法，更新dateRange
				this.dateRange = value;
				this.selectDate = selectDate.slice(0, -1);;
			},

			// 获取积分比例
			async getPointsRatio() {
				try {
					const res = await getPointsExchangeRatio();
					const data = res.Data;
					this.pointsRatio = data.PointToCNYRatio;
					console.log("获取到积分比例:", this.pointsRatio);
				} catch (error) {
					console.error("获取积分比例失败:", error);
					this.pointsRatio = 1;
				}
			},
			// 获取用户积分
			async getUserPoints() {
				try {
					const res = await getUserIntegral();
					if (res && res.Data) {
						this.userPoints = res.Data;
					}
				} catch (error) {
					console.error("获取用户积分失败:", error);
					this.userPoints = 0;
				}
			},

			// 刷新用户选择器中的数据
			refreshUserSelector() {
				if (this.$refs.userSelector) {
					// 如果用户选择器已经打开，则刷新数据
					this.$refs.userSelector.$vm.init();
				}
			},

			// 在组件销毁时移除监听器
			onUnload() {
				uni.$off("updateUserList");
			},

			// 获取默认收货地址
			async getDefaultAddress() {
				try {
					console.log("获取默认收货地址");
					const {
						Data
					} = await getAcceptAddressList({
						Index: 1,
						Size: 100,
					});

					if (Data && Data.length > 0) {
						// 查找默认地址，IsDefault值为1的地址
						const defaultAddress = Data.find((item) => item.IsDefault === 1);

						if (defaultAddress) {
							console.log("找到默认收货地址:", defaultAddress.Name);
							// 设置为已选中的地址
							this.selectedAddress = {
								id: defaultAddress.Id,
								name: defaultAddress.Name,
								phone: defaultAddress.Mobile || "",
								province: defaultAddress.Province,
								city: defaultAddress.City,
								county: defaultAddress.County,
								address: defaultAddress.Address,
								isDefault: true,
							};
						} else {
							console.log("未找到默认收货地址");
						}
					} else {
						console.log("未获取到收货地址列表");
					}
				} catch (error) {
					console.error("获取默认收货地址失败:", error);
				}
			},
		},
	};
</script>

<template>
	<view class="predetermined-container">
		<!-- 酒店信息 -->
		<view class="hotel-info">
			<view class="hotel-image">
				<image :src="hotelInfo.image" mode="aspectFill"></image>
			</view>
			<view class="hotel-details">
				<view class="hotel-name">{{ hotelInfo.name }}</view>
				<!-- 	<view class="room-type" v-if="type === 13">{{
          hotelInfo.roomType
        }}</view> -->
				<view class="price" v-if="!shouldUsePoints">¥{{ hotelInfo.price }}</view>
				<view class="price points-price" v-else>{{ Math.ceil(hotelInfo.price * pointsRatio) }} 积分</view>
			</view>
		</view>

		<!-- 酒店入住信息 - 只在酒店类型显示 -->
		<view class="booking-info" v-if="
	    type === 13 &&
	    !(selectedSpecName && selectedSpecName.includes('预约套餐'))
	  ">
			<!-- 日历组件文档 https://wuui.cn/zh-CN/components/calendar.html -->
			<calendar ref="calendar" :startDate="datePickerStart" :endDate="datePickerEnd" @confirm="onDateChange"
				:insert="false" slideSwitchMode="vertical" mode="range" :date="dateRange" :selected="priceList">
			</calendar>

			<view class="date-range-display" @click="openCalendar">
				<view class="date-section">
					<view class="date-label">{{ $t("order.checkIn") }}</view>
					<view class="date-content">
						<text class="date-month">{{ checkInDate.month }}月</text>
						<text class="date-day">{{ checkInDate.day }}日</text>
						<text class="date-week">{{ checkInDate.weekDay }}</text>
					</view>
				</view>

				<view class="date-section">
					<view class="date-label">{{ $t("order.checkOut") }}</view>
					<view class="date-content">
						<text class="date-month">{{ checkOutDate.month }}月</text>
						<text class="date-day">{{ checkOutDate.day }}日</text>
						<text class="date-week">{{ checkOutDate.weekDay }}</text>
					</view>
				</view>

				<view class="nights-count">
					<view class="night-badge">{{ $t("order.nights", { count: nightsCount }) }}
						<image src="/static/home/right-arrow-black.png"></image>
					</view>
				</view>
			</view>
		</view>

		<!-- 门票日期和场次选择 - 只在门票或活动类型显示 -->
		<view class="ticket-booking-info" v-if="type === 11 || type === 18">
			<view class="info-title">{{ $t("order.useDate") }}</view>
			<view class="date-picker-area">
				<uni-datetime-picker type="date" v-model="ticketDate" :clear-icon="false" :start="datePickerStart"
					:end="datePickerEnd" @change="onTicketDateChange">
					<view class="ticket-date-display">
						<view class="selected-date">
							<text>{{ formatTicketDate }}</text>
							<uni-icons type="arrowright" size="16" color="#999"></uni-icons>
						</view>
					</view>
				</uni-datetime-picker>
			</view>

			<view class="time-slot-section" v-if="timeSlots.length > 0">
				<view class="title-row">
					<view class="info-title">{{ $t("order.selectTime") }}</view>
					<view class="time-tip">{{ $t("order.timeSlotTip") }}</view>
				</view>
				<view class="time-slot-list">
					<view v-for="(slot, index) in timeSlots" :key="index" class="time-slot-item" :class="{
              'selected-slot': selectedTimeSlot === index,
              'disabled-slot': !slot.available,
            }" @click="selectTimeSlot(index)">
						<text>{{ slot.startTime
              }}{{ slot.endTime ? " - " + slot.endTime : "" }}</text>
					</view>
				</view>
			</view>
		</view>

		<!-- 数量选择 - 所有类型都显示，但不同类型显示不同标题 -->
		<view class="room-count">
			<view class="room-count-header">
				<view class="info-title">
					<template v-if="type === 13">{{ $t("order.roomCount") }}</template>
					<template v-else-if="type === 11">{{
            $t("order.ticketCount")
          }}</template>
					<template v-else-if="type === 18">{{
            $t("order.activityQuota")
          }}</template>
					<template v-else>{{ $t("order.productCount") }}</template>
				</view>
				<view class="count-control">
					<view class="count-btn minus" @click="decreaseRoom">
						<text class="minus-icon">-</text>
					</view>
					<view class="count-number">{{ roomNum }}</view>
					<view class="count-btn plus" @click="increaseRoom">
						<text class="plus-icon">+</text>
					</view>
				</view>
			</view>
		</view>


		<view class="table-box" v-if="
        type === 13 &&
        selectedSpecName &&
        !selectedSpecName.includes('预约套餐') &&
        roomList.length > 0
      ">
			<view class="fee-table">
				<view class="fee-table-header">
					<text class="fee-th name">日期</text>
					<text class="fee-th">价格</text>
					<text class="fee-th">房间</text>
					<text class="fee-th">小计</text>
				</view>
				<view class="fee-table-row" v-for="(item, idx) in roomList" :key="idx">
					<text class="fee-td name">{{ item.date }}</text>
					<text class="fee-td">{{ item.price }}</text>
					<text class="fee-td">x{{ item.room }}</text>
					<text class="fee-td">{{ item.totalPrice }}</text>
				</view>
			</view>
		</view>

		<!-- 规格选择区域 - 不是门票或活动或酒店类型且有规格列表时显示 -->
		<view class="spec-selection" v-if="
        hotelInfo.ProductSpecList &&
        hotelInfo.ProductSpecList.length > 0 &&
        type !== 11 &&
        type !== 18 &&
        isReservation
      ">
			<view class="info-title">{{ $t("order.specSelect") }}</view>
			<view class="spec-list">
				<view v-for="spec in hotelInfo.ProductSpecList" :key="spec.Id" class="spec-item" :class="{
            'selected-spec': selectedService === spec.Id && type !== 13,
          }" @click="selectService(spec)">
					<!-- 添加规格图片 -->
					<view class="spec-image" v-if="spec.Img">
						<image :src="spec.Img" mode="aspectFill"></image>
					</view>
					<view class="spec-content">
						<view class="spec-name">{{ spec.Name }}</view>
						<!-- 添加规格名称 -->
						<view class="spec-sub-name" v-if="spec.SpecName">
							<!-- 将SpecName按空格分割，遍历显示 -->
							<view v-for="(item, idx) in spec.SpecName.split(' ')" :key="idx" class="spec-item-row">
								<template v-if="findAttributeName(item)">
									<text class="spec-attr-name">{{ findAttributeName(item) }}:</text>
									<text class="spec-attr-value">{{ item }}</text>
								</template>
								<template v-else>
									<text class="spec-attr-value">{{ item }}</text>
								</template>
							</view>
						</view>
						<view class="spec-price-info">
							<text class="current-price" v-if="!shouldUsePoints">¥{{ spec.Price }}</text>
							<text class="current-price points-price" v-else>{{ Math.round(spec.Price * pointsRatio) }}
								积分</text>
						</view>
					</view>
					<view class="radio-button">
						<view class="radio-inner" v-if="selectedService === spec.Id"></view>
					</view>
				</view>
			</view>
		</view>

		<!-- 备注 -->
		<view class="remarks">
			<view class="info-title">{{ $t("order.remarks") }}</view>
			<view class="input-wrapper">
				<input class="remark-input" type="text" v-model="remark" :placeholder="$t('goods.placeHolder')"
					placeholder-style="color: #999;" />
			</view>
		</view>

		<!-- 收货地址 - 仅在线上商品(type=2)时显示 -->
		<view class="address-info" v-if="type === 2">
			<view class="info-header">
				<view class="info-title">{{ $t("order.shippingAddress") }}</view>
			</view>

			<!-- 已选择的地址 -->
			<view class="selected-address" v-if="selectedAddress" @click="openAddressSelector">
				<view class="address-content">
					<view class="address-header">
						<text class="address-name">{{ selectedAddress.name }}</text>
						<text class="address-phone">{{ selectedAddress.phone }}</text>
					</view>
					<view class="address-detail">
						{{ selectedAddress.province }} {{ selectedAddress.city }}
						{{ selectedAddress.county }}
						{{ selectedAddress.address }}
					</view>
				</view>
				<view class="address-arrow">
					<uni-icons type="forward" size="16" color="#BBBBBB"></uni-icons>
				</view>
			</view>

			<!-- 未选择地址时的提示 -->
			<view class="no-address" v-else @click="openAddressSelector">
				<text class="no-address-tip">{{ $t("order.selectAddress") }}</text>
				<view class="address-arrow">
					<uni-icons type="forward" size="16" color="#BBBBBB"></uni-icons>
				</view>
			</view>
		</view>

		<!-- 游客信息 - 酒店、门票和活动需要显示，其他商品不需要 -->
		<view class="guest-info" v-if="[3, 11, 13, 15, 18].includes(type)">
			<view class="info-header">
				<view class="info-title">
					<template v-if="type === 13">{{
            $t("order.guestInfo.checkInPerson")
          }}</template>
					<template v-else-if="[3, 11, 15].includes(type)">{{
            $t("order.guestInfo.tourist")
          }}</template>
					<template v-else-if="type === 18">{{
            $t("order.guestInfo.participant")
          }}</template>
					<template v-else>{{ $t("order.guestInfo.title") }}</template>
				</view>
				<view class="add-guest-btn" @click="openUserSelector">
					<text class="add-icon">+</text>
					<text class="add-text">
						<template v-if="type === 13">{{
              $t("order.guestInfo.addCheckInPerson")
            }}</template>
						<template v-else-if="[3, 11, 15].includes(type)">{{
              $t("order.guestInfo.addTourist")
            }}</template>
						<template v-else-if="type === 18">{{
              $t("order.guestInfo.addParticipant")
            }}</template>
						<template v-else>{{ $t("order.guestInfo.add") }}</template>
					</text>
				</view>
			</view>

			<!-- 游客列表 -->
			<view class="guest-list">
				<view class="guest-item" v-for="(guest, index) in guests" :key="index">
					<view class="guest-index">
						<template v-if="type === 13">{{ $t("order.guestInfo.checkInPerson")
              }}{{ index + 1 }}</template>
						<template
							v-else-if="[3, 11, 15].includes(type)">{{ $t("order.guestInfo.tourist") }}{{ index + 1 }}</template>
						<template
							v-else-if="type === 18">{{ $t("order.guestInfo.participant") }}{{ index + 1 }}</template>
						<template v-else>{{ $t("order.guestInfo.contactPerson")
              }}{{ index + 1 }}</template>
					</view>
					<view class="guest-details">
						<text class="guest-name">{{ guest.name }}</text>
						<text class="id-number">- {{ guest.idCard.substring(0, 11) }}</text>
						<text class="id-full">{{ guest.idCard }}</text>
					</view>
					<view class="delete-btn" @click="removeGuest(index)">
						<text class="delete-icon">×</text>
					</view>
				</view>

				<!-- 没有游客时的提示 -->
				<view class="no-guest" v-if="guests.length === 0">
					<text class="no-guest-tip">
						<template v-if="type === 13">{{
              $t("order.guestInfo.addCheckInTip")
            }}</template>
						<template v-else-if="[3, 11, 15].includes(type)">{{
              $t("order.guestInfo.addTouristTip")
            }}</template>
						<template v-else-if="type === 18">{{
              $t("order.guestInfo.addParticipantTip")
            }}</template>
						<template v-else>{{ $t("order.guestInfo.addTip") }}</template>
					</text>
				</view>
			</view>
		</view>

		<!-- 优惠券区域 - 非积分模式才显示 -->
		<view class="coupon-area" v-if="!shouldUsePoints">
			<view class="coupon-section">
				<view class="coupon-header">
					<view class="info-title">{{ $t("order.coupon.title") }}</view>
					<view class="coupon-status" v-if="useCoupons.length > 0">
						{{
              $t("order.coupon.selected", {
                count: useCoupons.length,
                amount: couponTotalDiscount.toFixed(2),
              })
            }}
					</view>
					<view class="coupon-status available" v-else-if="hasCoupons">
						{{ $t("order.coupon.available") }}
					</view>
					<view class="coupon-status unavailable" v-else>
						{{ $t("order.coupon.unavailable") }}
					</view>
				</view>
				<view class="coupon-selection" @click="navigateToCoupons">
					<view class="select-text">{{ $t("order.coupon.select") }}</view>
					<uni-icons type="forward" size="16" color="#BBBBBB"></uni-icons>
				</view>
			</view>
		</view>

		<!-- 预定须知 -->
		<view class="booking-notice">
			<view class="info-title">{{ $t("order.bookingNotice") }}</view>
			<view class="notice-content">
				<mp-html :content="hotelInfo.bookingNotice" />
			</view>
		</view>

		<hz-safe-area></hz-safe-area>

		<!-- 同意条款区域 -->
		<view class="agreement-row">
			<view class="agreement-icon" @click="changeCheked">
				<uni-icons v-if="checked" type="circle-filled" color="#1AAC19" size="26" class="agreementIcon" />
				<uni-icons v-else type="circle" color="#1AAC19" size="26" class="agreementIcon" />
			</view>
			<view class="agreement-container">
				<text>我已阅读协议</text>、
				<text class="blueText" @click.stop="goToTermsDetail(5773)">《用户协议》</text>丶
				<text class="blueText" @click.stop="goToTermsDetail(5774)">《隐私政策》</text>丶
				<text class="blueText" @click.stop="goToTermsDetail(5775)">《免责声明》</text>
			</view>
		</view>

		<!-- 底部结算栏 -->
		<view class="bottom-bar">
			<view class="bottom-bar_inner">
				<view class="price-section">
					<text class="price-label" v-if="!shouldUsePoints">{{ $t("order.orderAmount") }} ¥</text>
					<text class="price-label" v-else>{{ $t("order.orderPoints") }}</text>
					<template v-if="!shouldUsePoints">
						<u-count-to class="total-price" ref="countTo" :start-val="Number(lastTotalPrice)"
							:end-val="Number(totalPrice)" :duration="1000" :decimals="2" :autoplay="true"
							:color="'#FF4B31'" :bold="true" :fontSize="28"></u-count-to>
					</template>
					<template v-else>
						<text class="total-price points">{{ totalPoints }}</text>
					</template>
				</view>
				<view class="submit-btn" @click="submitOrder">
					<text>{{ $t("order.submitOrder") }}</text>
				</view>
			</view>
			<hz-safe-area></hz-safe-area>
		</view>

		<!-- 地址选择弹窗 -->
		<uni-popup ref="addressSelector" type="bottom">
			<view class="popup-content">
				<view class="popup-header">
					<text class="popup-title">{{ $t("order.shippingAddress") }}</text>
					<text class="popup-close" @click="closeAddressSelector">×</text>
				</view>
				<view class="popup-body">
					<select-address :selectedAddress="selectedAddress" @select="onAddressSelected"
						@complete="onAddressSelectComplete"></select-address>
				</view>
			</view>
		</uni-popup>

		<!-- 用户选择弹窗 -->
		<uni-popup ref="userSelector" type="bottom">
			<view class="popup-content">
				<view class="popup-header">
					<text class="popup-title">选择用户</text>
					<text class="popup-close" @click="closeUserSelector">×</text>
				</view>
				<view class="popup-body">
					<select-user :selectedGuests="currentSelectedGuests" @select="onUserSelected"
						@clear="onClearSelection" @complete="onSelectComplete"></select-user>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<style scoped lang="scss">
	.table-box {
		width: 100%;
		padding: 20rpx;
		border-radius: 12rpx;
		background-color: #fff;
		margin-bottom: 20rpx;

		.fee-table {
			background: #fff;
			overflow: hidden;

			.fee-table-header,
			.fee-table-row {
				display: flex;
				align-items: center;
				padding: 18rpx 0;
			}

			.fee-table-header {
				background: #f5f5f5;
				font-weight: bold;
				font-size: 28rpx;

				.fee-th {
					flex: 1;
					text-align: center;
					padding-left: 20rpx;

					&.name {
						flex: 1.5;
					}
				}
			}

			.fee-table-row {
				border-bottom: 1rpx solid #eee;
				font-size: 28rpx;

				.fee-td {
					flex: 1;
					text-align: center;
					padding-left: 20rpx;

					&.name {
						flex: 1.5;
					}
				}

				&:last-child {
					border-bottom: none;
				}
			}
		}
	}

	// 布局容器
	.predetermined-container {
		padding: 30rpx 30rpx 226rpx;
		background-color: #f5f5f5;
		min-height: 100vh;
	}

	// 卡片组件
	.hotel-info,
	.booking-info,
	.ticket-booking-info,
	.room-count,
	.remarks,
	.guest-info,
	.booking-notice,
	.coupon-area,
	.address-info {
		background-color: #fff;
		border-radius: 12rpx;
		padding: 30rpx;
		margin-bottom: 20rpx;
	}

	// 酒店信息
	.hotel-info {
		display: flex;
		align-items: center;

		.hotel-image {
			width: 120rpx; // 缩小图片宽度，避免被挤压
			height: 120rpx;
			border-radius: 8rpx;
			overflow: hidden;
			margin-right: 20rpx;

			image {
				width: 100%;
				height: 100%;
			}
		}

		.hotel-details {
			flex: 1;
			min-width: 0; // 允许内容收缩，防止挤压图片

			.hotel-name {
				font-size: 28rpx; // 原32rpx，缩小2个字号
				font-weight: 600;
				color: #333;
				margin-bottom: 10rpx;
				white-space: normal; // 支持换行
				word-break: break-all; // 长单词/英文换行
				overflow-wrap: break-word;
				line-height: 1.3;
				max-height: 2.6em; // 最多两行
				overflow: hidden;
			}

			.room-type {
				font-size: 28rpx;
				color: #666;
			}

			.price {
				font-size: 36rpx;
				color: #498fff;
				font-weight: bold;
				margin-top: 10rpx;

				&.points-price {
					color: #ff4b31;
				}
			}
		}
	}

	// 日期选择
	.date-range-display {
		display: flex;
		align-items: center;
		justify-content: space-between;
		width: 100%;
		padding: 20rpx 0;
	}

	.date-section {
		flex: 1;

		.date-label {
			font-size: 24rpx;
			color: #666;
			margin-bottom: 10rpx;
		}

		.date-content {
			display: flex;
			align-items: baseline;

			.date-day,
			.date-month {
				font-size: 28rpx;
				color: #333;
				font-weight: bold;
			}

			.date-month {
				margin-left: 8rpx;
			}

			.date-week {
				font-size: 28rpx;
				color: #666;
				margin-left: 16rpx;
			}
		}
	}

	.nights-count {
		padding-left: 20rpx;

		.night-badge {
			font-size: 24rpx;
			color: #666;

			image {
				height: 24rpx;
				width: 13rpx;
				margin-left: 10rpx;
			}
		}
	}

	// 通用标题
	.info-title {
		font-size: 30rpx;
		font-weight: 500;
		color: #333;
		margin-bottom: 20rpx;
	}

	// 计数控制
	.room-count-header {
		display: flex;
		justify-content: space-between;
		align-items: center;
	}

	.count-control {
		display: flex;
		align-items: center;

		.count-btn {
			width: 60rpx;
			height: 60rpx;
			border-radius: 30rpx;
			display: flex;
			align-items: center;
			justify-content: center;
			background-color: #f5f5f5;

			&.minus {
				color: #999;
			}

			&.plus {
				color: #fff;
				background-color: #498fff;
			}
		}

		.count-number {
			margin: 0 30rpx;
			font-size: 32rpx;
			font-weight: 500;
			color: #333;
		}

		.minus-icon,
		.plus-icon {
			font-size: 40rpx;
			line-height: 1;
		}
	}

	// 输入框
	.input-wrapper {
		background-color: #f5f5f5;
		border-radius: 8rpx;
		padding: 20rpx;

		.remark-input {
			width: 100%;
			font-size: 28rpx;
			color: #333;
		}
	}

	// 游客信息
	.guest-info {
		.info-header {
			display: flex;
			justify-content: space-between;
			align-items: center;
			margin-bottom: 20rpx;

			.add-guest-btn {
				display: flex;
				align-items: center;
				background-color: #f8f8f8;
				padding: 6rpx 16rpx;
				border-radius: 30rpx;

				.add-icon {
					font-size: 28rpx;
					color: #498fff;
					margin-right: 6rpx;
				}

				.add-text {
					color: #498fff;
					font-size: 24rpx;
				}
			}
		}

		.guest-list {
			.guest-item {
				display: flex;
				align-items: center;
				padding: 20rpx 0;
				border-bottom: 1rpx solid #eee;

				&:last-child {
					border-bottom: none;
				}

				.guest-index {
					font-size: 28rpx;
					color: #666;
					margin-right: 20rpx;
					min-width: 80rpx;
				}

				.guest-details {
					flex: 1;

					.guest-name {
						font-size: 28rpx;
						color: #333;
					}

					.id-number {
						font-size: 28rpx;
						color: #666;
						margin-left: 10rpx;
					}

					.id-full {
						display: block;
						font-size: 24rpx;
						color: #999;
						margin-top: 6rpx;
					}
				}

				.delete-btn {
					width: 60rpx;
					height: 60rpx;
					display: flex;
					align-items: center;
					justify-content: center;

					.delete-icon {
						font-size: 36rpx;
						color: #ccc;
					}
				}
			}

			.no-guest {
				padding: 40rpx 0;
				text-align: center;

				.no-guest-tip {
					font-size: 28rpx;
					color: #999;
				}
			}
		}
	}

	// 优惠券区域
	.coupon-area {
		background-color: #fff;
		border-radius: 12rpx;
		padding: 30rpx;
		margin-bottom: 20rpx;
	}

	.coupon-section {
		.coupon-header {
			display: flex;
			align-items: center;
			margin-bottom: 20rpx;

			.info-title {
				margin-bottom: 0;
				margin-right: 20rpx;
			}

			.coupon-status {
				flex: 1;
				font-size: 24rpx;
				color: #498fff;

				&.available {
					color: #498fff;
				}

				&.unavailable {
					color: #999;
				}
			}
		}

		.coupon-selection {
			display: flex;
			justify-content: space-between;
			align-items: center;
			height: 80rpx;
			padding: 0 20rpx;
			background-color: #f5f5f5;
			border-radius: 8rpx;

			.select-text {
				font-size: 28rpx;
				color: #666;
			}
		}
	}

	// 门票日期和场次选择
	.ticket-date-display {
		display: flex;
		align-items: center;
		background-color: #f5f5f5;
		padding: 20rpx;
		border-radius: 8rpx;
	}

	.selected-date {
		display: flex;
		align-items: center;
		justify-content: space-between;
		width: 100%;
		font-size: 28rpx;
		color: #333;
	}

	.time-slot-section {
		margin-top: 20rpx;
	}

	.title-row {
		display: flex;
		align-items: baseline;
		justify-content: space-between;
		margin-bottom: 20rpx;
	}

	.time-tip {
		font-size: 24rpx;
		color: #999;
	}

	.time-slot-list {
		display: flex;
		flex-wrap: wrap;
		margin-top: 20rpx;
	}

	.time-slot-item {
		width: 48%;
		height: 80rpx;
		line-height: 80rpx;
		text-align: center;
		background-color: #f5f5f5;
		border-radius: 8rpx;
		margin-bottom: 20rpx;
		color: #333;
		font-size: 28rpx;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
		padding: 0 10rpx;
		box-sizing: border-box;
		position: relative;

		&:nth-child(odd) {
			margin-right: 4%;
		}

		&.selected-slot {
			background-color: #498fff;
			color: #fff;
		}

		&.disabled-slot {
			background-color: #f5f5f5;
			color: #aaaaaa;
			border: 1px dashed #dddddd;
		}
	}

	.date-picker-area {
		margin-bottom: 30rpx;
	}

	// 须知内容
	.notice-text {
		font-size: 26rpx;
		color: #666;
		line-height: 1.6;
	}

	.agreement-row {
		position: fixed;
		left: 0;
		bottom: 166rpx;
		display: flex;
		align-items: flex-start;
		align-items: center;
		background-color: #fff;
		padding: 24rpx;
		z-index: 11;
		border-bottom: 2rpx solid #f0f0f0;

		.agreement-icon {
			width: 10%;
			margin-right: 16rpx;
		}

		.agreement-container {
			flex: 1;
			display: flex;
			flex-wrap: wrap;
			font-size: 28rpx;
		}

		.blueText {
			color: #2796ff;
		}
	}

	// 底部栏
	.bottom-bar {
		position: fixed;
		bottom: 0;
		left: 0;
		right: 0;
		background-color: #fff;
		box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.05);

		.bottom-bar_inner {
			display: flex;
			height: 100rpx;
			align-items: center;
			padding: 0 30rpx;
			width: 100%;
		}

		.price-section {
			flex: 1;
			display: flex;
			align-items: baseline;

			.price-label {
				font-size: 26rpx;
				color: #666;
			}

			.total-price {
				font-size: 40rpx;
				color: #498fff;
				font-weight: bold;

				&.points {
					color: #ff4b31;
				}
			}
		}

		.submit-btn {
			background: linear-gradient(135deg, #498fff 0%, #3a7fe6 100%);
			border-radius: 40rpx;
			height: 80rpx;
			padding: 0 50rpx;
			display: flex;
			align-items: center;
			justify-content: center;

			text {
				color: #fff;
				font-size: 30rpx;
				font-weight: 500;
			}
		}
	}

	// 弹窗样式
	.popup-content {
		width: 100%;
		background-color: #fff;
		border-radius: 12rpx;
		overflow: hidden;

		.popup-header {
			display: flex;
			justify-content: space-between;
			align-items: center;
			padding: 30rpx;
			border-bottom: 1rpx solid #eee;

			.popup-title {
				font-size: 32rpx;
				font-weight: 500;
				color: #333;
			}

			.popup-close {
				font-size: 40rpx;
				color: #999;
				line-height: 1;
			}
		}

		.popup-body {
			max-height: 800rpx;
			overflow-y: auto;
		}
	}

	// 其他服务选择样式
	.service-selection {
		background-color: #fff;
		border-radius: 12rpx;
		padding: 30rpx;
		margin-bottom: 20rpx;
	}

	.service-list {
		.service-item {
			display: flex;
			align-items: flex-start;
			padding: 20rpx 0;
			border-bottom: 1rpx solid #eee;

			&:last-child {
				border-bottom: none;
			}

			&.selected-service {
				background-color: rgba(73, 143, 255, 0.05);
			}

			.service-left {
				width: 160rpx;
				height: 160rpx;
				margin-right: 20rpx;
				border-radius: 8rpx;
				overflow: hidden;

				.service-image {
					width: 100%;
					height: 100%;
					object-fit: cover;
				}
			}

			.service-content {
				flex: 1;
				padding-right: 20rpx;

				.service-name {
					font-size: 28rpx;
					color: #333;
					margin-bottom: 16rpx;
					line-height: 1.4;
				}

				.service-price-info {
					margin-bottom: 12rpx;

					.current-price {
						font-size: 32rpx;
						color: #498fff;
						font-weight: bold;
					}

					.market-price {
						font-size: 24rpx;
						color: #999;
						text-decoration: line-through;
						margin-left: 12rpx;
					}
				}

				.service-stock {
					font-size: 24rpx;
					color: #666;
				}
			}

			.radio-button {
				width: 40rpx;
				height: 40rpx;
				border-radius: 50%;
				border: 2rpx solid #999;
				margin: 10rpx 0 0 20rpx;
				flex-shrink: 0;
				display: flex;
				align-items: center;
				justify-content: center;

				.radio-inner {
					width: 24rpx;
					height: 24rpx;
					border-radius: 50%;
					background-color: #498fff;
				}
			}
		}
	}

	// 收货地址样式
	.address-info {
		background-color: #fff;
		border-radius: 12rpx;
		padding: 30rpx;
		margin-bottom: 20rpx;

		.selected-address {
			display: flex;
			align-items: center;
			background-color: #f5f5f5;
			border-radius: 8rpx;
			padding: 20rpx;

			.address-content {
				flex: 1;

				.address-header {
					display: flex;
					align-items: center;
					margin-bottom: 10rpx;

					.address-name {
						font-size: 28rpx;
						color: #333;
						font-weight: 500;
						margin-right: 20rpx;
					}

					.address-phone {
						font-size: 26rpx;
						color: #666;
					}
				}

				.address-detail {
					font-size: 26rpx;
					color: #666;
					line-height: 1.4;
				}
			}

			.address-arrow {
				margin-left: 10rpx;
			}
		}

		.no-address {
			display: flex;
			align-items: center;
			justify-content: space-between;
			background-color: #f5f5f5;
			border-radius: 8rpx;
			padding: 30rpx 20rpx;

			.no-address-tip {
				font-size: 28rpx;
				color: #666;
			}
		}
	}

	// 规格选择区域
	.spec-selection {
		background-color: #fff;
		border-radius: 12rpx;
		padding: 30rpx;
		margin-bottom: 20rpx;
	}

	.spec-list {
		.spec-item {
			display: flex;
			align-items: center;
			padding: 20rpx 0;
			border-bottom: 1rpx solid #eee;

			&:last-child {
				border-bottom: none;
			}

			&.selected-spec {
				background-color: rgba(73, 143, 255, 0.05);
			}

			// 规格图片
			.spec-image {
				width: 80rpx;
				height: 80rpx;
				border-radius: 8rpx;
				overflow: hidden;
				margin-right: 20rpx;
				flex-shrink: 0;

				image {
					width: 100%;
					height: 100%;
					object-fit: cover;
				}
			}

			.spec-content {
				flex: 1;
				padding-right: 20rpx;

				.spec-name {
					font-size: 28rpx;
					color: #333;
					margin-bottom: 8rpx;
					line-height: 1.4;
				}

				// 规格子名称
				.spec-sub-name {
					font-size: 24rpx;
					color: #666;
					margin-bottom: 8rpx;
					line-height: 1.4;
					display: flex;
					flex-wrap: wrap;
					gap: 20rpx;

					.spec-attr-name {
						color: #888;
						margin-right: 4rpx;
					}

					.spec-attr-value {
						color: #333;
					}

					.spec-item-row {
						display: flex;
						margin-bottom: 4rpx;
						flex-wrap: wrap;
					}
				}

				.spec-price-info {
					margin-bottom: 12rpx;

					.current-price {
						font-size: 32rpx;
						color: #498fff;
						font-weight: bold;

						&.points-price {
							color: #ff4b31;
						}
					}

					.market-price {
						font-size: 24rpx;
						color: #999;
						text-decoration: line-through;
						margin-left: 12rpx;
					}
				}
			}

			.radio-button {
				width: 40rpx;
				height: 40rpx;
				border-radius: 50%;
				border: 2rpx solid #999;
				margin: 10rpx 0 0 20rpx;
				flex-shrink: 0;
				display: flex;
				align-items: center;
				justify-content: center;

				.radio-inner {
					width: 24rpx;
					height: 24rpx;
					border-radius: 50%;
					background-color: #498fff;
				}
			}
		}
	}
</style>